<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <div>
            <table>
                <tr>
                    <th v-for="(item,index) in userList" :key="item.id" :class="{active:ac===index}"
                        @click="showContent(index)">
                        {{item.title+"&nbsp;&nbsp;"}}
                    </th>
                </tr>
            </table>
        </div>
        <div style="margin-top: 20px;  width: 200px;
        height: 50px;
        background-color: #E35885;
        text-align: center;">
            选择了:<a v-if="ac!==null">
                <th>{{userList[ac].content}}</th>
            </a>

        </div>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                ac: null,
                userList: [
                    { id: 1, title: "HTML", content: "HTML" },
                    { id: 2, title: "CSS", content: "CSS" },
                    { id: 3, title: "JavaScript", content: "JavaScript" },
                    { id: 4, title: "Vue.js", content: "Vue.js" },

                ],
            },
            methods: {
                showContent(index) {
                    this.ac = index;
                },
            }
        });
    </script>

</body>

</html>